/**
 * Created by zander on 2018/1/17.
 */

function getPieDate() {
    $.ajax({
        type: "GET",
        url: "/intest/v1/getAllData",
        success: function (ret) {
            if (ret.status == "0000") {
                $('#container').highcharts({
                    chart: {
                        plotBackgroundColor: null,
                        plotBorderWidth: null,
                        plotShadow: false
                    },
                    title: {
                        text: '自动化测试执行总数占比'
                    },
                    tooltip: {
                        headerFormat: '{series.name}<br>',
                        pointFormat: '{point.name}: <b>{point.percentage:.1f}%</b>'
                    },
                    plotOptions: {
                        pie: {
                            allowPointSelect: true,
                            cursor: 'pointer',
                            dataLabels: {
                                enabled: true,
                                formatter: function () {
                                    return '<span style="color: ' + this.point.color + '"> 总数：' + this.y + '，占比' +
                                        Highcharts.numberFormat(this.percentage, 2) + '%</span>';
                                },
                                style: {
                                    color: (Highcharts.theme && Highcharts.theme.contrastTextColor) || 'black'
                                }
                            },
                            showInLegend: true
                        }
                    },
                    series: [{
                        type: 'pie',
                        name: '自动化测试执行总数占比',
                        data: [
                            ['闪电借款', ret.content['jkAll']],
                            ['速递', ret.content['sdAll']],
                            ['掌E贷',ret.content['zedAll']],
                        ]
                    }]
                });
            }
        },
        error: function () {
            alert("Error 500,请联系开发人员！");
        }
    });
}


function getPieDate1() {
    $.ajax({
        type: "GET",
        url: "/intest/v1/getAllData",
        success: function (ret) {
            if (ret.status == "0000") {
                $('#container1').highcharts({
                    chart: {
                        plotBackgroundColor: null,
                        plotBorderWidth: null,
                        plotShadow: false
                    },
                    title: {
                        text: '借款自动化执行次数占比'
                    },
                    tooltip: {
                        headerFormat: '{series.name}<br>',
                        pointFormat: '{point.name}: <b>{point.percentage:.1f}%</b>'
                    },
                    plotOptions: {
                        pie: {
                            allowPointSelect: true,
                            cursor: 'pointer',
                            dataLabels: {
                                enabled: true,
                                formatter: function () {
                                    return '<span style="color: ' + this.point.color + '"> 总数：' + this.y + '，占比' +
                                        Highcharts.numberFormat(this.percentage, 2) + '%</span>';
                                },
                                style: {
                                    color: (Highcharts.theme && Highcharts.theme.contrastTextColor) || 'black'
                                }
                            },
                            showInLegend: true
                        }
                    },
                    series: [{
                        type: 'pie',
                        name: '借款自动化执行次数占比',
                        data: [
                            ['极速测试', ret.content['jkInstant']],
                            ['快速测试', ret.content['jkQuick']],
                            ['全流程',ret.content['jk']],
                            ['借款接口',ret.content['jkAPI']],
                        ]
                    }]
                });
            }
        },
        error: function () {
            alert("Error 500,请联系开发人员！");
        }
    });
}


function getPieDate2() {
    $.ajax({
        type: "GET",
        url: "/intest/v1/getAllData",
        success: function (ret) {
            if (ret.status == "0000") {
                $('#container2').highcharts({
                    chart: {
                        plotBackgroundColor: null,
                        plotBorderWidth: null,
                        plotShadow: false
                    },
                    title: {
                        text: '速递自动化执行次数占比'
                    },
                    tooltip: {
                        headerFormat: '{series.name}<br>',
                        pointFormat: '{point.name}: <b>{point.percentage:.1f}%</b>'
                    },
                    plotOptions: {
                        pie: {
                            allowPointSelect: true,
                            cursor: 'pointer',
                            dataLabels: {
                                enabled: true,
                                formatter: function () {
                                    return '<span style="color: ' + this.point.color + '"> 总数：' + this.y + '，占比' +
                                        Highcharts.numberFormat(this.percentage, 2) + '%</span>';
                                },
                                style: {
                                    color: (Highcharts.theme && Highcharts.theme.contrastTextColor) || 'black'
                                }
                            },
                            showInLegend: true
                        }
                    },
                    series: [{
                        type: 'pie',
                        name: '速递自动化执行次数占比',
                        data: [
                            ['极速测试', ret.content['sdInstant']],
                            ['快速测试', ret.content['sdQuick']],
                            ['全流程',ret.content['sd']],
                            ['速递接口',ret.content['sdAPI']],
                        ]
                    }]
                });
            }
        },
        error: function () {
            alert("Error 500,请联系开发人员！");
        }
    });
}

function getPieDate3() {
    $.ajax({
        type: "GET",
        url: "/intest/v1/getAllData",
        success: function (ret) {
            if (ret.status == "0000") {
                $('#container3').highcharts({
                    chart: {
                        plotBackgroundColor: null,
                        plotBorderWidth: null,
                        plotShadow: false
                    },
                    title: {
                        text: '掌E贷自动化执行次数占比'
                    },
                    tooltip: {
                        headerFormat: '{series.name}<br>',
                        pointFormat: '{point.name}: <b>{point.percentage:.1f}%</b>'
                    },
                    plotOptions: {
                        pie: {
                            allowPointSelect: true,
                            cursor: 'pointer',
                            dataLabels: {
                                enabled: true,
                                formatter: function () {
                                    return '<span style="color: ' + this.point.color + '"> 总数：' + this.y + '，占比' +
                                        Highcharts.numberFormat(this.percentage, 2) + '%</span>';
                                },
                                style: {
                                    color: (Highcharts.theme && Highcharts.theme.contrastTextColor) || 'black'
                                }
                            },
                            showInLegend: true
                        }
                    },
                    series: [{
                        type: 'pie',
                        name: '掌E贷自动化执行次数占比',
                        data: [
                            ['极速测试', ret.content['zedInstant']],
                            ['快速测试', ret.content['zedQuick']],
                            ['全流程',ret.content['zed']],
                            ['掌E贷接口',ret.content['zedAPI']],
                        ]
                    }]
                });
            }
        },
        error: function () {
            alert("Error 500,请联系开发人员！");
        }
    });
}
window.onload = getPieDate();
window.onload = getPieDate1();
window.onload = getPieDate2();
window.onload = getPieDate3();